package com.wiki.gds.user.provider.security.oauth2.config;

import com.wiki.gds.base.common.dto.ResponseDto;
import com.wiki.gds.base.common.exception.BizExceptionEnum;
import com.wiki.gds.base.web.controller.support.HttpKit;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component("restAuthenticationEntryPoint")
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint {

    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) throws IOException, ServletException {
        HttpKit.responseJson(response,new ResponseDto(BizExceptionEnum.NOT_LOGIN));
    }
}